<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>
<#assign css>
<#--此ftl中用到的css-->
</#assign>
<#assign js>
<#--此ftl中用到的js-->
<script>
	$(".btn-submit").click(function () {
		// 校验表单合法
		var bootstrapValidator = $(".form-edit").data('bootstrapValidator');
		bootstrapValidator.validate();
		if(bootstrapValidator.isValid()){
			$.ajax({
				type: "POST",
				url: "/service/oneclass/edit",
				data: $(".form-edit").serialize(),
				dataType: "JSON",
				success: function(res){
				    if(res.code=='0'){
                        layer.msg(res.message, {time: 1000
                        }, function(){
                            location.href="/service/oneclass/index";
                        });
					}else if(res.code=='-1'){
                        layer.msg(res.message);

					}else if(res.code=='2'){
				        layer.confirm('该分类目前处于停用状态，是否立即启用?',{icon: 3, title: '提示'},function(){
                            $.ajax({
                                type: "POST",
                                dataType: "json",
                                url: "/service/oneclass/active/"+res.message,
                                success: function (res) {
                                    layer.msg(res.message, {time: 1000}, function () {
                                        location.href="/service/oneclass/index";
                                    });
                                }
                            });

						})

					}


				}
			});
		}else{
			return false;
		}
	});

	$('.form-edit').bootstrapValidator({
		message: '请输入有效值',
		feedbackIcons: {
			valid: 'glyphicon glyphicon-ok',
			invalid: 'glyphicon glyphicon-remove',
			validating: 'glyphicon glyphicon-refresh'
		}
	});

</script>
</#assign>
<@layout title="编辑" active="oneclass">
<!-- Content Header (Page header) -->
<section class="content-header">
	<h1>
		<#if isAdd>
            新增
        <#else>
            编辑
        </#if>
		<small>服务业务</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="/"><i class="fa fa-home"></i> 管理后台</a></li>
		<li><a href="/service/oneclass/index"><i class="fa fa-list-ul"></i> 服务业务设置</a></li>
		<li class="active"><i class="fa fa-edit"></i>
		    <#if isAdd>
                新增
            <#else>
                编辑
            </#if>
		</li>
	</ol>
</section>
<!-- Main content -->
<section class="content">
	<div class="row">
		<div class="col-md-12">
			<!-- Default box -->
			<div class="box  box-primary">
				<form class="form-horizontal form-edit" method="post" action="/service/oneclass/edit">
					<div class="box-body">
						<input type="hidden" id="id" name="id" value="${oneClass.id!}">
						<input type="hidden" id="isAdd" name="isAdd" value="${isAdd?string('true','false')}">
						<div class="form-group">
							<label class="col-sm-2 control-label">服务名称：</label>
							<div class="col-sm-10">
								<#--<@my.select id="serviceClass" datas=getDict('SERVICE_CLASS') value="${oneClass.serviceClass!}" required="true" defaultValue="请选择"/>-->
								<select required="true" id="serviceClass" name="serviceClass" class="form-control">
									<#list serviceList as service>
										<option value="${service.serviceClass}">${service.serviceName}</option>

									</#list>

								</select>


							</div>
						</div>


					<div class="box-footer">
						<button type="button" class="btn btn-default btn-back">返回</button>
						<button type="button" class="btn btn-info pull-right btn-submit">添加</button>
					</div>

				</form>
			</div>
			<!-- /.box -->
		</div>
	</div>
</section>
<!-- /.content -->
</@layout>
